-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: can: sam: use UPLL clock instead of PLLA clock #45223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: can: sam: use UPLL clock instead of PLLA clock #45223
Conversation
|
The |
|
Hi @henrikbrixandersen , |
May you check if below enables UPLLCK at 480 MHz: diff --git a/soc/arm/atmel_sam/same70/soc.c b/soc/arm/atmel_sam/same70/soc.c
index 77a7fe0cf3..bd0e77c9ae 100644
--- a/soc/arm/atmel_sam/same70/soc.c
+++ b/soc/arm/atmel_sam/same70/soc.c
@@ -177,6 +177,15 @@ static ALWAYS_INLINE void clock_init(void)
;
}
+ /* Setup UPLL */
+ PMC->CKGR_UCKR = CKGR_UCKR_UPLLCOUNT(0x3Fu);
+ | CKGR_UCKR_UPLLEN;
+
+ /* Wait for PLL lock */
+ while (!(PMC->PMC_SR & PMC_SR_LOCKU)) {
+ ;
+ }
+
/*
* Final setup of the Master Clock
*/ |
Thanks! I do not have access to the hardware, but perhaps @shaoanxli can check? |
Is there any good way to get UPLLCK? It seems no register to get the UPLLCK. From the SAM E70 data sheet, page 277: |
The below is supposed to work. diff --git a/soc/arm/atmel_sam/same70/soc.c b/soc/arm/atmel_sam/same70/soc.c
index 77a7fe0cf3..bd0e77c9ae 100644
--- a/soc/arm/atmel_sam/same70/soc.c
+++ b/soc/arm/atmel_sam/same70/soc.c
@@ -177,6 +177,15 @@ static ALWAYS_INLINE void clock_init(void)
;
}
+ /* Setup UPLL */
+ PMC->CKGR_UCKR = CKGR_UCKR_UPLLCOUNT(0x3Fu);
+ | CKGR_UCKR_UPLLEN;
+
+ /* Wait for PLL lock */
+ while (!(PMC->PMC_SR & PMC_SR_LOCKU)) {
+ ;
+ }
+
/*
* Final setup of the Master Clock
*/ |
|
The UPLLCK seems to setup successfully , but the test failed , logs and console output shows: |
Hi @shaoanxli, Let me check! |
This error seems to occur here(drivers/can/can_common.c) , when bitrate=800000 : |
The Without those changes there are no changes to the CAN timing calculations. |
80cde34 to
e55b155
Compare
|
@shaoanxli, @nandojve I have tried to incorporate the needed changes as good as I can from studying the datasheet and the suggested code from @nandojve. Please test - both the CAN timing test cases and the actual CAN bitrate as presented on the CAN bus. @alexanderwachter You wrote the original driver - can you assist in testing? |
Hi folks, There is nothing wrong with this patch. You just need select correct divisor at devicetree. With 24 CAN clock will be 20MHz. Please, change it to 6 then clock will be 80MHz. See below result at SAMV71_XULT: BTW, don't forget to add |
e55b155 to
471b550
Compare
|
@nandojve Thank you so much for your help on co-authoring and verifying this fix :) I have marked it ready for review. |
Hi @henrikbrixandersen , you are welcome! |
Enable the UTMI PLL (UPLL) clock and add a static definition of its clock frequency. Signed-off-by: Henrik Brix Andersen <[email protected]> Co-authored-by: Gerson Fernando Budke <[email protected]>
Enable the UTMI PLL (UPLL) clock and add a static definition of its clock frequency. Signed-off-by: Henrik Brix Andersen <[email protected]> Co-authored-by: Gerson Fernando Budke <[email protected]>
Use the UPLLCK clock for the CAN controller as recommended by the Atmel SAM E70 data sheet. Move the configuration of the clock prescaler from Kconfig to devicetree and limit it to the values recommended by the SAM E70 datasheet. Fixes: zephyrproject-rtos#45012 Signed-off-by: Henrik Brix Andersen <[email protected]>
Remove unnecessary #address-cells/#size-cells from the CAN devicetree nodes. Signed-off-by: Henrik Brix Andersen <[email protected]>
471b550 to
a20bfae
Compare
Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cannot get my hands on the HW at the moment. Did somebody test?
Edit: never mind. Test results were hidden in the APP 🤦♂️
I tried the test on the HW . The test pass. |

Use the UPLLCK clock for the CAN controller as recommended by the Atmel SAM E70 data sheet.
Fixes: #45012
Signed-off-by: Henrik Brix Andersen [email protected]